package cn.com.cifi.mars.entity;

import java.math.BigDecimal;

import cn.com.cifi.mars.constant.IsDeleteEnum;
import cn.com.cifi.mars.constant.WhetherEnum;
import cn.com.cifi.mars.util.BigDecimalUtils;
import cn.com.cifi.mars.util.NumberUtils;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

/**
 * <p>
 * 回款计划版本明细表
 * </p>
 *
 * @author JingYuanXiang
 * @since 2020-11-06
 */
@Data
@TableName("t_return_plan_version_detail")
public class ReturnPlanVersionDetail implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.INPUT)
    private String id;

    @ApiModelProperty(value = "回款计划版本id")
    private String versionId;

    @ApiModelProperty(value = "组团id")
    private String groupId;

    @ApiModelProperty(value = "组团code")
    private String groupCode;

    @ApiModelProperty(value = "组团名称")
    private String groupName;

    @ApiModelProperty(value = "产品构成父级编码")
    private String proProductCode;

    @ApiModelProperty(value = "产品构成父级名称")
    private String proProductType;

    @ApiModelProperty(value = "产品构成code")
    private String productCode;

    @ApiModelProperty(value = "产品构成名称")
    private String productName;

    @ApiModelProperty(value = "经营方式编码")
    private String businessType;

    @ApiModelProperty(value = "经营方式名称")
    private String businessTypeName;

    @ApiModelProperty(value = "装修方式编码")
    private String freeType;

    @ApiModelProperty(value = "装修方式名称")
    private String freeTypeName;

    @ApiModelProperty(value = "产品属性编码（属性标签）")
    private String proType;

    @ApiModelProperty(value = "产品属性名称（属性标签）")
    private String proTypeName;

    @ApiModelProperty(value = "组合业态编码")
    private String combinationProductCode;

    @ApiModelProperty(value = "组合业态名称")
    private String combinationProductName;

    @ApiModelProperty(value = "签约金额")
    private BigDecimal signAmount;

    @ApiModelProperty(value = "实际签约金额")
    private BigDecimal actualSignAmount;

    @ApiModelProperty(value = "计划签约金额")
    private BigDecimal planSignAmount;

    @ApiModelProperty(value = "增量回款-实际数")
    private BigDecimal incrementReturnAmountActual;

    @ApiModelProperty(value = "存量回款-实际数")
    private BigDecimal storeReturnAmountActual;

    @ApiModelProperty(value = "增量回款-测算数")
    private BigDecimal incrementReturnAmountCalculate;

    @ApiModelProperty(value = "存量回款-测算数")
    private BigDecimal storeReturnAmountCalculate;

    @ApiModelProperty(value = "增量回款-调整数")
    private BigDecimal incrementReturnAmountAdjust;

    @ApiModelProperty(value = "存量回款-调整数")
    private BigDecimal storeReturnAmountAdjust;

    @ApiModelProperty(value = "签约应收回款（NOS专用）")
    private BigDecimal signReceivableAmount;

    @ApiModelProperty(value = "月初应收")
    private BigDecimal earlyReceivableAmount;

    @ApiModelProperty(value = "本月应收")
    private BigDecimal receivableAmount;

    @ApiModelProperty(value = "上月应收未收")
    private BigDecimal lastMonthNotReceivableAmount;

    @ApiModelProperty(value = "已签未回回款数")
    private BigDecimal signedUnrecovered;

    @ApiModelProperty(value = "期初应退回款数")
    private BigDecimal refundable;

    @ApiModelProperty(value = "增量回款-本期回款数")
    private BigDecimal incrementReturnAmount;

    @ApiModelProperty(value = "存量回款-本期回款数")
    private BigDecimal storeReturnAmount;

    @ApiModelProperty(value = "回款合计-本期回款数")
    private BigDecimal totalReturnAmount;

    @ApiModelProperty(value = "期末应收-本期回款数")
    private BigDecimal finalReceivable;

    @ApiModelProperty(value = "累计年度签约合计")
    BigDecimal yearSignAmountTotal;

    @ApiModelProperty(value = "累计签约合计")
    BigDecimal signAmountTotal;

    @ApiModelProperty(value = "累计年度回款合计")
    BigDecimal yearReturnAmountTotal;

    @ApiModelProperty(value = "累计回款合计")
    BigDecimal returnAmountTotal;

    @ApiModelProperty(name = "signReturnRate", value = "累计签约回款率")
    BigDecimal signReturnRate;

    @ApiModelProperty(name = "annualOverallReturnRate", value = "年度综合回款率")
    BigDecimal annualOverallReturnRate;

    @ApiModelProperty(value = "回款计划日期")
    private LocalDateTime returnTime;

    @ApiModelProperty(value = "编制是否完成")
    private Integer isEstablishment;

    @ApiModelProperty(value = "是否允许删除(0.否 1.是)")
    private Integer isAllowedDelete;

    @ApiModelProperty(value = "是否删除(0.否 1.是)")
    private Integer isDelete;

    @ApiModelProperty(value = "创建人员")
    private String createBy;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "更新人员")
    private String updateBy;

    @ApiModelProperty(value = "更新时间")
    private LocalDateTime updateTime;


    public void initialize(LocalDateTime dateTime,String alias) {
        this.setReturnTime(dateTime);
        this.setSignAmount(BigDecimal.ZERO);
        this.setActualSignAmount(BigDecimal.ZERO);
        this.setPlanSignAmount(BigDecimal.ZERO);
        //增量回款-实际数
        this.setIncrementReturnAmountActual(BigDecimal.ZERO);
        //存量回款-实际数
        this.setStoreReturnAmountActual(BigDecimal.ZERO);
        //增量回款-测算数
        this.setIncrementReturnAmountCalculate(BigDecimal.ZERO);
        //存量回款-测算数
        this.setStoreReturnAmountCalculate(BigDecimal.ZERO);
        //增量回款-调整数
        this.setIncrementReturnAmountAdjust(BigDecimal.ZERO);
        //存量回款-调整数
        this.setStoreReturnAmountAdjust(BigDecimal.ZERO);
        //签约应收回款（NOS专用）
        this.setSignReceivableAmount(BigDecimal.ZERO);
        //月初应收
        this.setEarlyReceivableAmount(BigDecimal.ZERO);
        //本月应收
        this.setReceivableAmount(BigDecimal.ZERO);
        //上月应收未收
        this.setLastMonthNotReceivableAmount(BigDecimal.ZERO);
        //已签未回回款数
        this.setSignedUnrecovered(BigDecimal.ZERO);
        //期初应退回款数
        this.setRefundable(BigDecimal.ZERO);
        //增量回款-本期回款数
        this.setIncrementReturnAmount(BigDecimal.ZERO);
        //存量回款-本期回款数
        this.setStoreReturnAmount(BigDecimal.ZERO);
        //回款合计-本期回款数
        this.setTotalReturnAmount(BigDecimal.ZERO);
        //期末应收-本期回款数
        this.setFinalReceivable(BigDecimal.ZERO);

        this.setIsEstablishment(WhetherEnum.NO.getKey());
        this.setIsDelete(IsDeleteEnum.NO.getKey());
        this.setCreateTime(LocalDateTime.now());
        this.setCreateBy(alias);
        this.setUpdateTime(LocalDateTime.now());
        this.setUpdateBy(alias);

    }

}
